<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>菱形</title>
</head>
<body>
    <script>
        /*输入要打印的菱形的行数，显示对应形状的菱形*/
        var rows = prompt("请输入菱形的行数",3);
        for (var i = 0; i < rows; i++) {
            for (var j = 0; j < 2 * (rows - i - 1); j++) {
                document.write("&nbsp;");
            }
            for (var j = 0; j <= i; j++) {
                document.write("*");
                document.write("&nbsp;&nbsp;&nbsp;");
            }
            document.write("<br>");
        }
        for (var i = 0; i < rows - 1; i++) {
            for (var j = 0; j < 2 * (i + 1); j++) {
                document.write("&nbsp;");
            }
            for (var j = (rows - 1 - i); j > 0; j--) {
                document.write("*");
                document.write("&nbsp;&nbsp;&nbsp;");
            }
            document.write("<br>");
        }
    </script>
</body>
</html>